package com.lizx.persional.resource;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.lizx.persional.common.utils.Result;
import com.lizx.persional.entity.UserInfo;
import com.lizx.persional.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * api
 * </p>
 *
 * @author 李振兴
 * @since 2018-02-27
 */
@RestController
@RequestMapping("/persional/userInfo")
public class UserInfoResource {
    @Autowired
    private UserInfoService userInfoService;

    /**
     * 根据userid获取用户基本资料
     *
     * @param userId
     * @return
     */
    @GetMapping("/get/{userId}")
    public Result getObjectByUserId(@PathVariable("userId") String userId) {
        EntityWrapper<UserInfo> ew = new EntityWrapper<>();
        ew.eq("user_id", userId);
        return Result.success(userInfoService.selectOne(ew));
    }

    /**
     * 更新个人信息
     * @param userInfo
     * @return
     */
    @PutMapping("/update")
    public Result update(@RequestBody UserInfo userInfo) {
        return Result.success(userInfoService.insertOrUpdate(userInfo));
    }
}

